package org.example.Thread01;

public class Dome_Thread01 {
    public static void main(String[] args) {
        //创建线程t1
        Thread t1 = new Thread(()->{
            while(true) {
                Thread thread=Thread.currentThread();
                System.out.println(thread.getName()+"  hello thread...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        //启动t1
        t1.start();
        //创建线程t2
        Thread t2 = new Thread(()->{
            while(true){
                //获取线程对象
                Thread thread=Thread.currentThread();
                System.out.println(thread.getName()+"  我是一个有名字的线程...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"我有名字");
        //启动t2
        t2.start();
    }
}
